package top.wettis.chat.util;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import java.util.Collections;

public class MybatisPlusGenerator {
//    具体参数配置参考 https://baomidou.com/pages/981406
    public static void main(String[] args){
        FastAutoGenerator.create("jdbc:postgresql://121.5.17.184:5432/chatgpt",
                "wettis",
                "2314335207")

                .globalConfig(builder ->
                        builder.author("wettis")
                        .enableSwagger()
                        .outputDir(".\\temp")
                )
                .packageConfig(builder ->
                        builder.parent("top.wettis")
                        .moduleName("chat")
                        .entity("pojo.DO")
                        .pathInfo(Collections.singletonMap(OutputFile.xml, ".\\temp\\mapper"))
                )
                .strategyConfig(builder -> {
                    builder.addInclude("professor" , "resume" );
                    builder.entityBuilder()
                            .enableLombok()
                            .enableTableFieldAnnotation()
                            .enableRemoveIsPrefix()
                            .logicDeleteColumnName("is_del");
                    builder.controllerBuilder()
                            .enableFileOverride()
                            .enableRestStyle();
                    builder.serviceBuilder()
                            .enableFileOverride();
                    builder.mapperBuilder()
                            .enableFileOverride()
                            .enableBaseResultMap();
                })

                .templateEngine(new FreemarkerTemplateEngine())

                .execute();
    }
}
